import request from '@/utils/request'

// 查询列表
export function listPlatinfos(query) {
  return request({
    url: '/system/platinfos/list',
    method: 'get',
    params: query
  })
}

// 查询详细
export function getPlatinfos(advPlatinfosId) {
  return request({
    url: '/system/platinfos/' + advPlatinfosId,
    method: 'get'
  })
}

// 新增
export function addPlatinfos(data) {
  data.infocontent = formatInfoContent(data.infocontent);
  return request({
    url: '/system/platinfos',
    method: 'post',
    data: data
  })
}

// 修改
export function updatePlatinfos(data) {
  data.infocontent = formatInfoContent(data.infocontent);
  return request({
    url: '/system/platinfos',
    method: 'put',
    data: data
  })
}

// 删除
export function delPlatinfos(advPlatinfosId) {
  return request({
    url: '/system/platinfos/' + advPlatinfosId,
    method: 'delete'
  })
}
// 设置默认视频
export function updateByDefault(data) {
  return request({
    url: '/system/platinfos/updateByDefault',
    method: 'post',
    data: data
  })
}

function formatInfoContent(infocontent) {
  infocontent = infocontent.replaceAll('<img', 'aImg');
  infocontent = infocontent.replaceAll('<p style=\"line-height: 1.5;\">', 'startP');
  infocontent = infocontent.replaceAll('</p>', 'endP');
  infocontent = infocontent.replaceAll('\t', 'aTap');
  return infocontent;
}
